package com.boss.fileapp.util;

import org.springframework.util.StringUtils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DateUtils {

    public static DateTimeFormatter getFormatter(String formatter){
        String pattern;
        if(!StringUtils.isEmpty(formatter)){
            pattern = formatter;
        }else{
            pattern = "yyyy-MM-dd HH:mm:ss";
        }
        return DateTimeFormatter.ofPattern(pattern);
    }

    public static String getCurrentTimeStr(String formatter){
        LocalDateTime localDateTime = LocalDateTime.now();
        return localDateTime.format(getFormatter(formatter));
    }


}
